package ndk.caro.tools;

import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Point;

public class myTool {
	 public static Bitmap resize(Bitmap bitmapOrg,int newWidth,int newHeight) {
	    	int width = bitmapOrg.getWidth();
	 		int height = bitmapOrg.getHeight();
	 		float scaleWidth = (float) newWidth / width;
	 		float scaleHeight = (float) newHeight / height;
	 		Matrix matrix = new Matrix();
	 		matrix.postScale(scaleWidth, scaleHeight);
	 		Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,width, height, matrix, true);
	 		
			return resizedBitmap;
		}
	 
	 public static Point returnPointFromString(String str) {
			int pos = 0;		
			
			for(int i = 0; i< str.length(); i++) {
				if(str.charAt(i) == '|') {
					pos = i;
				}
			}
			
		 return new Point(
				 Integer.parseInt(str.substring(0,pos)),
				 Integer.parseInt(str.substring(pos + 1, str.length()))
				 );
	 }
	 
	 public static String returnStringFromPointF(Point pnt) {
		 String st = pnt.x + "|" + pnt.y;
		 return st;
	 }
}
